package edu.jmu.transaction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Transactional(propagation=Propagation.REQUIRED,
isolation=Isolation.DEFAULT,readOnly=false)
@Service("accountServiceAnnotation")
public class AccountServiceAnnotationImpl implements AccountService {

	private AccountDao accountDao;
	
	@Autowired
	public void setAccountDao(AccountDao accountDao) {
		this.accountDao = accountDao;
	}


	@Override
	public void transfer(String from, String to, int money) {
		accountDao.transferFrom(from, money);
		accountDao.displayAllAccount();
		int x = 1/0;//转账途中抛出异常
		accountDao.transferTo(to, money);
	}

}
